package graph

import "fmt"

type Graph struct {
	V   int
	E   int
	adj []Bag
}

func (g *Graph) validateVertex(v int) {
	if v < 0 || v >= g.V {
		panic(fmt.Sprintf("vertext %d is not between 0 and %d", v, g.V-1))
	}
}

func (g *Graph) AddEdge(v int, w int) {
	g.validateVertex(v)
	g.validateVertex(w)
	g.E++
	g.adj[v].Add(w)
	g.adj[w].Add(v)
}
